package com.elvin.platform.udp;

import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.ip.udp.UnicastSendingMessageHandler;
import org.springframework.integration.support.MessageBuilder;

  /**
   * Integration发送方式
   */
  @Log4j2
  public class UdpIntegrationClient {


    @Autowired
    private UnicastSendingMessageHandler unicastSendingMessageHandler;

    public void sendMessage(String message) {
      log.info("发送UDP: {}", message);
      unicastSendingMessageHandler.handleMessage(MessageBuilder.withPayload(message).build());
      log.info("发送成功");
    }
  }
